//
//  ActivityCell.m
//  XDCommonApp
//
//  Created by XD-XY on 7/17/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "ActivityCell.h"

@implementation ActivityCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor clearColor];
        [self initViews];
    }
    return self;
}

-(void)initViews
{
    
    titleIV = [UIView initViewRect:CGRectMake(0, 10.5, 320, 44) andBackGroudColor:[UIColor whiteColor]];
    
    self.titleLB = [UILabel initLabelRect:CGRectMake(15,10+12,290,20) andBackGroudColor:[UIColor whiteColor] andTextFont:[UIFont boldSystemFontOfSize:17] andTextColor:RGBA(130, 130, 130, 1) andTextAlignment:NSTextAlignmentLeft];
    
    self.FirstGood = [[GoodsItem alloc] initWithFrame:CGRectMake(0, height_y(titleIV)+0.5f, 106, 140)];
    self.secondGood = [[GoodsItem alloc] initWithFrame:CGRectMake(width_x(_FirstGood)+1,_FirstGood.frame.origin.y,_FirstGood.frame.size.width, _FirstGood.frame.size.height)];
    self.thridGood = [[GoodsItem alloc] initWithFrame:CGRectMake(width_x(_secondGood)+1,_FirstGood.frame.origin.y,_FirstGood.frame.size.width, _FirstGood.frame.size.height)];
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goodsClick:)];
    [_FirstGood addGestureRecognizer:tap];
    UITapGestureRecognizer * tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goodsClick:)];
    [_secondGood addGestureRecognizer:tap1];
    UITapGestureRecognizer * tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goodsClick:)];
    [_thridGood addGestureRecognizer:tap2];
    
    //line
    [self createLineViews];
    
    [self.contentView addSubview:titleIV];
    [self.contentView addSubview:_titleLB];
    [self.contentView addSubview:_FirstGood];
    [self.contentView addSubview:_secondGood];
    [self.contentView addSubview:_thridGood];
    
}

-(void)createLineViews
{
    UIImageView * lineIV1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10, UI_SCREEN_WIDTH, 1/2.0f)];
    lineIV1.image = [UIImage imageNamed:@"line"];
    [self.contentView addSubview:lineIV1];
    
    UIImageView * lineIV2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, height_y(titleIV), UI_SCREEN_WIDTH, 1/2.0f)];
    lineIV2.image = [UIImage imageNamed:@"line"];
    [self.contentView addSubview:lineIV2];
    
    UIImageView * lineIV3 = [[UIImageView alloc] initWithFrame:CGRectMake(106.0f,height_y(titleIV), 1/2.0f, 140.0f)];
    lineIV3.image = [UIImage imageNamed:@"sepLine"];
    [self.contentView addSubview:lineIV3];
    
    UIImageView * lineIV4 = [[UIImageView alloc] initWithFrame:CGRectMake(213, height_y(titleIV), 1/2.0f, 140)];
    lineIV4.image = [UIImage imageNamed:@"sepLine"];
    [self.contentView addSubview:lineIV4];
    
    UIImageView * lineIV5 = [[UIImageView alloc] initWithFrame:CGRectMake(0,height_y(_FirstGood), UI_SCREEN_WIDTH, 1/2.0f)];
    lineIV5.image = [UIImage imageNamed:@"line"];
    [self.contentView addSubview:lineIV5];
}

-(void)goodsClick:(UITapGestureRecognizer *)tap
{
    [_delegate chooseGoods:tap];
}

-(void)setDataDict:(NSDictionary *)dataDict
{
    if (_dataDict!=nil){
        _dataDict = nil;
    }
    _dataDict = dataDict;
    _titleLB.text = @"秒杀";
    _FirstGood.tag = 1001;
    _secondGood.tag = 1002;
    _thridGood.tag = 1003;
    
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
